#ifndef SCENE_H
#define SCENE_H

#include "objet.h"
#include "billboard.h"
#include "lumiere.h"
#include "mouseListener.h"
#include "mouseMotionListener.h"
#include "mousePassiveMotionListener.h"
#include "keyboardListener.h"
#include "timerListener.h"
#include "texture.h"
#include "neon.h"
#include "glow.h"

#include <GL/glut.h>

#include <list>
using namespace std;
class Neon;

class Scene
{
  public:
  friend class WindowCreator;
  //constructeur
  Scene();
  //destructeur
  ~Scene();
  ////////////////////////////
  //manipulations des objets//
  ////////////////////////////
  bool addObjet(Objet *objet);
  bool removeObjet(Objet *objet);
  
  bool addNeon(Neon* neon);
  bool removeNeon(Neon* neon);

  bool addKeyboardListener(KeyboardListener *keyboardListener);
  bool removeKeyboardListener(KeyboardListener *keyboardListener);
  
  bool addMouseListener(MouseListener *mouseListener);
  bool removeMouseListener(MouseListener *mouseListener);
 
  bool addMouseMotionListener(MouseMotionListener *mouseMotionListener);
  bool removeMouseMotionListener(MouseMotionListener *mouseMotionListener);

  bool addMousePassiveMotionListener(MousePassiveMotionListener *mousePassiveMotionListener);
  bool removeMousePassiveMotionListener(MousePassiveMotionListener *mousePassiveMotionListener);

  bool addTimerListener(TimerListener *objet);
  bool removeTimerListener(TimerListener *objet);

 /////////////////////////////
  //manipulation des lumieres//
  /////////////////////////////
  bool addLumiere(Lumiere *l);
  bool removeLumiere(Lumiere *l);
  
  ////////////////////////
  //gestion de la camera//
  ////////////////////////
  void setCameraPosition(const float x, const float y, const float z);
  void getCameraPosition(float &x, float &y, float &z);
  
  void setCameraVerticale(const float x, const float y, const float z);
  void getCameraVerticale(float &x, float &y, float &z);
  
  void setPointObservation(const float x, const float y, const float z);
  void getPointObservation(float &x, float &y, float &z);
  
  /////////////////////////////////////
  //comparaison distance camera/objet//
  /////////////////////////////////////
  static bool plusEloigne(Objet *a, Objet *b);
  void getAngleRotation(float &anglex , float &angley);
static void clignChange(void);
static void updateDefil(float forceVent);
static bool showTips;
static int clign;
static int sens;
static float defil;
  protected:
  
  void _initGL();
  //////////////////
  //les evenements//
  //////////////////
  void _display();
  void _mouse(int bouton, int etat, int x, int y);
  void _mouseMotion(int x, int y);
  void _mousePassiveMotion(int x, int y);
  void _keyboard(unsigned char key, int x, int y);
  void _reshape(int width, int height);
  void _timer(int value);
  void _menuCallback(int item);

  ////////////////////////////
  //liste des objets a gerer//
  ////////////////////////////
  list<Objet*> _objets;
  list<Neon*> _neons;
  list<KeyboardListener*> _keyboardListeners;
  list<MouseListener*> _mouseListeners;
  list<TimerListener*> _timerListeners;
  list<MouseMotionListener*> _mouseMotionListeners;
  list<MousePassiveMotionListener*> _mousePassiveMotionListeners;


  ///////////////////////
  //gestion des lumiere//
  ///////////////////////
  list<Lumiere *> _lumieres;
  list<int> _lightIDs;//liste  des indices dispo
  
  //////////////////////////////
  //gestion deplacement souris//
  //////////////////////////////
  bool _presse;//bouton presse?
  int _xold, _yold;
  int _anglex, _angley;
  
  ////////////////////////
  //gestion de la camera//
  ////////////////////////
  float _cameraX, _cameraY, _cameraZ;//position de la camera
  float _cameraVertX, _cameraVertY, _cameraVertZ;//axe vertical de la camera
  float _pointObsX, _pointObsY, _pointObsZ;//position du point observe

  Billboard *_arbreCourant;//l'arbre que l'on veut placer

};
#endif
